//----------------------------------------------------------------
#include <iostream>
#include "TestGame.h"
#include <assert.h>
//----------------------------------------------------------------
class BOx : public Box{
	
public:
	float spdX, spdY;
	BOx() : Box()
	{
		spdX = 90;
		spdY = 60;
		rotZ = 45;
		rotX = 45;
		rotY = 45;
	}

	virtual void Update()
	{
		if((posX + Width + spdX < 500) && (posX + spdX > 100))
		{
			posX += spdX * Timer::instance->getDT();
		}
		else
			spdX = -spdX;

		if ((posY + Height + spdY < 500) && (posY + spdY > 100))
		{
			posY += spdY * Timer::instance->getDT();
		}
		else
			spdY = -spdY;

		//resetVertexs();
	}
};


TestGame::TestGame (HINSTANCE hInstance)
: Game (hInstance)
{
	fpsSkip = 0;
}
//----------------------------------------------------------------
TestGame::~TestGame ()
{

}
//----------------------------------------------------------------
bool TestGame::OnStartUp ()
{
	sprite = NULL;
	tex = NULL;
	vertices[0] = new Circle(10);
	vertices[1] = new Triangle();
	vertices[2] = new Box();
	

	/*for(int i = 1; i < MAXSHAPES; i++)
	{
		vertices[i]->setBounds(100 + 100 * i,200,50,50);
		vertices[i]->setColor(0xff00ff00);
	}*/
	vertices[0]->setBounds(100,200,100,100);
	vertices[0]->setColor(0xffff0000);
	vertices[1]->setBounds(200,200,50,50);
	vertices[1]->setColor(0xff00ff00);
	vertices[2]->setBounds(20,10,5000,5000);
	vertices[2]->setColor(0xff00ff00);
	

	tex = new tex_ptr(new Texture("..\\assets\\Kirby sprite [drshnaps].png", 0xff8080ff));//xff8080ff
	
	render->loadTexture(tex);
	sprite = new Sprite();
	
	sprite->SetTexture(tex);
	sprite->setBounds(0,0,100,100);
	return true;
}
//----------------------------------------------------------------
bool TestGame::OnLoop ()
{
	sprite->Draw(render);
	//MAXSHAPES
	for(int i = 0; i < MAXSHAPES; i++)
	{
		vertices[i]->Update();
		vertices[i]->Draw(render);
	}

	sprite->Draw(render);

	if(fpsSkip == 5)
	{
		fpsSkip = 0;
		float fps = Timer::instance->getFPS();

		char * fpsS = new char[30];

		sprintf(fpsS, "FPS: %f", fps);

		m_pkWindows->SetWindowTitle(fpsS);
	}
	fpsSkip++;
	return false;
}
//----------------------------------------------------------------
bool TestGame::OnShutDown ()
{
	for(int i = 0; i < MAXSHAPES;i++)
	{
		delete vertices[i];
	}
	if (tex)
		delete tex;
	if (sprite)
		delete sprite;
	return true;
}
//----------------------------------------------------------------
